export default function request(url, data, method = "GET") {
  return new Promise((resolve, reject) => {
    wx.request({
      // url: "http://codervans.vaiwan.com" + url, //  钉钉内网穿透地址
      url: "http://123.207.32.32:9001" + url,
      // url:'http://localhost:3000'+url,
      data,
      method,
      header: {
        cookie: wx.getStorageSync("cookies")
          ? wx
              .getStorageSync("cookies")
              .find((item) => item.indexOf("MUSIC_U") !== -1)
          : "",
      },
      success: (res) => {
        if (url === "/login/cellphone") {
          wx.setStorage({
            key: "cookies",
            data: res.cookies,
          });
        }
        resolve(res.data);
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
}
